﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Expressing_Label
{
    public partial class WelcomeForm : Form
    {
        private bool c_isFrmMoving = false;
        private Point c_ptCuurentPosition = new Point();
        public static PublicResources g_pbResources;

        public WelcomeForm()
        {
            InitializeComponent();
            g_pbResources = new PublicResources();
        }


     /*   private void Configure_btn_Click(object sender, EventArgs e)
        {
            this.Hide();
            ConfigurationFrm cff = new ConfigurationFrm();
            cff.Owner = this;
            cff.Show();
        }*/
        private void Configure_btn_Click(object sender, EventArgs e)
        {
            this.Hide();
            checkpassword chpass = new checkpassword();
            chpass.Owner = this;
            chpass.Show();
        }

        private void User_btn_Click(object sender, EventArgs e)
        {
            this.Hide();
            VideoForm vf = new VideoForm();
            vf.Owner = this;
            vf.Show();
        }

        private void WelcomeForm_MouseDown(object sender, MouseEventArgs e)
        {
            c_isFrmMoving = true;
            c_ptCuurentPosition = MousePosition;
        }

        private void WelcomeForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (c_isFrmMoving)
            {
                this.Left += MousePosition.X - c_ptCuurentPosition.X;
                this.Top += MousePosition.Y - c_ptCuurentPosition.Y;
                c_ptCuurentPosition = MousePosition;
            }
        }

        private void WelcomeForm_MouseUp(object sender, MouseEventArgs e)
        {
            c_isFrmMoving = false;
        }

        private void WelcomeForm_MouseLeave(object sender, EventArgs e)
        {
            c_isFrmMoving = false;
        }

        private void WelcomeForm_Activated(object sender, EventArgs e)
        {
            this.Refresh();
        }

        private void Configure_btn_MouseEnter(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            b.Top -= 1;
            b.Left -= 1;
        }

        private void Configure_btn_MouseLeave(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            b.Top += 1;
            b.Left += 1;
        }

        private void WelcomeForm_Load(object sender, EventArgs e)
        {
            if(PublicResources.g_iConfiguraState == 6)
            {
                this.Hide();
                VideoForm vf = new VideoForm();
                vf.Owner = this;
                vf.Show();
            }
            //using (var db = new db_FACEEntities())
            //{
            //    var result = (from info in db.tb_ExpressingInfo
            //                  select new
            //                  {
            //                      ID = info.ID,
            //                      ImageLocation = info.ImageLocation,
            //                      CurrentVideoTime = info.CurrentVideoTime
            //                  }).ToArray();
            //    FileStream fs = new FileStream(@"Data\Time.Data",FileMode.OpenOrCreate);
            //    StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            //    string ts = string.Empty;
            //    for (int i = 0; i < result.Count(); i++)
            //    {
            //        ts = string.Empty;
            //        ts += result[i].ID.ToString() + "," + result[i].ImageLocation.ToString() + "," + result[i].CurrentVideoTime.ToString();
            //        sw.WriteLine(ts);
            //    }
            //    sw.Dispose();
            //    fs.Dispose();
                                  
            //}
        }

    }
}
